home
***
CD-ROM
|
disk
|
FTP
|
other
***
search
/
Games of Daze
/
Infomagic - Games of Daze (Summer 1995) (Disc 1 of 2).iso
/
x2ftp
/
msdos
/
convert
/
mod15ins
/
3115.c
< prev
next >
Wrap
C/C++ Source or Header
|
1995-04-10
|
2KB
|
82 lines
#include <string.h> /* pour les gestions de strings */
#include <stdio.h> /* pour printf et les fichiers */
#include <io.h> /* pour filelenght et eof */
#include <dos.h> /* pour getdfree */
#include <stdlib.h> /* pour exit */
char *destname (char *name) {
char *buf = " " ;
strcpy (buf, name) ;
strncpy (buf, "_", 1) ;
return buf;
}
int main (int nbparam, char *param[] ) {
FILE *src, *dest ;
unsigned char buf1 [469], buf2 [129] , buf3 [32000] ;
int i=0,j=0,s ;
printf ("\nMOD 4 CH 31 INSTR to 15 INSTR converter \n") ;
printf ("Coded by Fred of TFL-TDV \n \n") ;
if (nbparam != 2) {
printf ("Syntax: 3115 <filename> \n") ;
exit (0) ;
}
if (strcmp (destname (param [1]),param [1]) == 0) {
printf("I don't want to convert a file with \n") ;
printf("a name beginning by '_'. Sorry guy !\n\n") ;
exit (1) ;
}
if ((src=fopen(param[1],"rb")) == NULL) {
printf ("File '%s' not found in current directory.\n",param[1]) ;
printf ("Type 3115 without any parameter for help\n \n");
exit (1) ;
}
if ((dest=fopen(destname(param[1]),"wb")) == NULL) {
printf ("Cannot open destination file. \n \n") ;
exit (1) ;
}
/* Convertion : */
for ( i=0 ; i<470 ; i++ ) {
buf1 [i] = getc (src) ;
if (feof(src) != 0) {
printf ("Too early eof error -Is this a mod ? \n \n") ;
exit (1) ;
} }
fseek(src,950,SEEK_SET);
for ( i=0 ; i<130 ; i++ ) {
buf2 [i] = getc (src) ;
if (feof(src) != 0) {
printf ("Too early eof error -Is this a mod ? \n \n") ;
exit (1) ;
} }
for ( i=0 ; i<470 ; i++ )
putc ( buf1 [i] , dest ) ;
for ( i=0 ; i<130 ; i++ )
putc ( buf2 [i] , dest ) ;
fseek(src,1084,SEEK_SET);
while (feof(src) == 0) {
buf3 [j] = getc(src) ;
j++ ;
if (j == 32000) {
for (i=0 ; i<32000 ; i++) putc (buf3 [i] , dest) ;
j = 0 ;
}
}
for (i=0 ; i<=j ; i++)
putc (buf3 [i] , dest) ;
printf("Converted module is '%s'.\n\n",destname (param[1]) ) ;
return 0 ;
}